
	<?php
        header("Content-Type:text/html;charset=utf-8");
		if(isset($_REQUEST['name_1'])&&isset($_REQUEST['title'])){
		  $name = $_REQUEST['name_1'];
          $title = $_REQUEST['title'];
          @$body_1 = $_REQUEST['body_1'];
          $text_name = "text_data.txt";
          $text_data = $name."!".$title."!".$body_1."\r\n";
          $fp = fopen($text_name,"a");
          $fw = fwrite($fp,$text_data);
          fclose($fp);       
          echo "成功写入";

		}
        
       $text_name = "text_data.txt";
        $handle = fopen($text_name,"r");
        $arr = fread($handle,filesize($text_name));
        $arr = str_replace("\r\n","!",$arr);
        $arr = explode("!",$arr);
       // print_r($arr);
        $n = count($arr)-1;
        //echo $n ;
        $name = array();
        $j = 1;
        $title = array();
        $k = 0;
        $body_1 = array();
        $l = 0;
        for($i=0;$i<$n;$i++){
            if($i == 0){
               // echo "<br/>".$arr[$i]."<br/>";
               $name[0] = $arr[$i];
               //echo "1";
            }else if($i%3 == 0){
               // echo "<hr/>".$arr[$i];
               $name[$j++] = $arr[$i];
            }else if($i%3 == 1){
                $title[$k++] = $arr[$i];
            }else{
                $body_1[$l++] = $arr[$i];
            }
            
        }
        //echo "<br/>";
        //print_r($body_1);
        
            echo "<table border='1'>";
            for($i=0;$i<count($name);$i++){
                echo "<tr><td>Name</td><td>".$name[$i]."</td></tr>";
                 echo "<tr><td>Title</td><td>".$title[$i]."</td></tr>";
                  echo "<tr><td>Body</td><td>".$body_1[$i]."</td></tr>";                
            }

          echo "</table>";
        echo "结束";
        fclose($handle);
	?>
